import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import './plugins/element.js'
/* 导入全局样式 */
import '@/assets/css/global.css'
/* 导入字体图示 */
import '@/assets/fonts/iconfont.css'
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'
/* 导入富文本编辑器 */
import VueQuillEditor from 'vue-quill-editor'

// require styles
/* 导入富文本编辑器样式 */
import 'quill/dist/quill.core.css'
import 'quill/dist/quill.snow.css'
import 'quill/dist/quill.bubble.css'

Vue.prototype.$http = axios
/* 配置axios请求根路径 */
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
/* 通过axios发送的请求，设置请求拦截器，进行预处理，添加token  config请求对象 */
axios.interceptors.request.use(config => {
  config.headers.Authorization = window.sessionStorage.getItem('token')
  return config
})

Vue.use(VueQuillEditor)
Vue.config.productionTip = false
Vue.component('tree-table', TreeTable)
Vue.filter('dateFormat', function (originVal) {
  const d = new Date(originVal)
  const y = d.getFullYear()
  const m = (d.getMonth() + 1 + '')
  const date = (d.getDate() + '').padStart(2, 0)
  const h = (d.getHours() + '').padStart(2, 0)
  const min = (d.getMinutes() + '').padStart(2, 0)
  const s = (d.getSeconds() + '').padStart(2, 0)
  return `${y}-${m}-${date} ${h}:${min}:${s}`
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
